<template>
  <div id="app" class="oval-header pd-all">
    <van-grid :border="false" :column-num="msgTags.length" class="msg-head-tags">
      <van-grid-item v-for="tag in msgTags" :key="tag.key">
        <a @click="gopage(tag.key)">
          <img :src="tag.image" alt="">
          <p>{{tag.name}}</p>
        </a>
      </van-grid-item>
    </van-grid>
    <msg-list />

    <slogan class="mg-footer"/>
    <footer-nav :unread="unread" page="message"/>
  </div>
</template>

<script>
	import { 
    Grid, 
    GridItem,
  } from "vant";
  import Footer from "@cmpt/footer"
  import MsgList from "../components/msg-list"
  import { MSG_LIST_TABS } from '@utils/default_config';
  import Slogan from '@cmpt/slogan'

  import { getRole } from '@utils/role'

  export default {
    name: "App",
    data(){
        return {
          loading: false,
          is_finished: false,
          allTabs: MSG_LIST_TABS,
          role: getRole(),
          msgTags: [],
          messageList: [],
          unread: localStorage.msg_unread_num || ''
        }
    },
    components:{
      [Footer.name]: Footer,
      [MsgList.name]: MsgList,
      [Grid.name]: Grid,
      [GridItem.name]: GridItem,
      [Slogan.name]: Slogan,
    },
    created() {
      if(this.role === '0'){
        this.allTabs.splice(this.allTabs.findIndex(item => item.key === 3), 1)
      }
      this.msgTags = this.allTabs
    },
    methods: {
      gopage (key) {
        this.$goPage('message/list', {'type': key})
      }
    }
  }
</script>

<style lang="less" scoped>
@import "~@style_m/basic/utils/index";
@import "~@style_m/components/body-bg";
  .oval-header {
    min-height: 50px;
    &:after {
      background-size: 100% 100px;
    }
  }
  .msg-head-tags {
    margin: 20px 0 12px;
    text-align: center;
    border-radius: 5px;
    overflow: hidden;
    a {
      display: block;
      padding: 15px 0;
    }
    p{
      color: @black;
      margin-top: 10px;
    }
    img {
      max-height: 24px;
      width: auto;
    }
  }
</style>
